<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>DOM编程</title>
	<script>
		function getParagraphNum(){
			//获取文档中由p标记形成的集合(数组)
			var pEles = document.getElementsByTagName('p');
			var count = pEles.length;
			console.log(count);
		}
	</script>
</head>
<body>
	<p>段落1</p>
	<p>段落2</p>
	<div>
		<h1>标题1</h1>
		<p>段落1</p>
		<h2>标题2</h2>
	</div>
	<input type="button" value="单击我,统计页面中段落的数量" onclick="getParagraphNum()">
</body>
</html>